package com.yanfan.zutai.service.impl;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.yanfan.zutai.domain.BDeviceTime;
import com.yanfan.zutai.mapper.BDeviceTimeMapper;
import com.yanfan.zutai.service.IBDeviceTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 设备定时Service业务层处理
 *
 * @author ruoyi
 * @date 2021-12-07
 */
@Service
public class BDeviceTimeServiceImpl implements IBDeviceTimeService {
    @Autowired
    private BDeviceTimeMapper bDeviceTimeMapper;

    /**
     * 查询设备定时
     *
     * @param id 设备定时ID
     * @return 设备定时
     */
    @Override
    public BDeviceTime selectBDeviceTimeById(Long id) {
        return bDeviceTimeMapper.selectBDeviceTimeById(id);
    }

    /**
     * 查询设备定时列表
     *
     * @param bDeviceTime 设备定时
     * @return 设备定时
     */
    @Override
    public List<BDeviceTime> selectBDeviceTimeList(BDeviceTime bDeviceTime) {
        return bDeviceTimeMapper.selectBDeviceTimeList(bDeviceTime);
    }

    /**
     * 新增设备定时
     *
     * @param bDeviceTime 设备定时
     * @return 结果
     */
    @Override
    public int insertBDeviceTime(BDeviceTime bDeviceTime) {
        Snowflake snowflake = IdUtil.getSnowflake(6, 2);
        long id = snowflake.nextId();
        bDeviceTime.setId(id);
        return bDeviceTimeMapper.insertBDeviceTime(bDeviceTime);
    }

    /**
     * 修改设备定时
     *
     * @param bDeviceTime 设备定时
     * @return 结果
     */
    @Override
    public int updateBDeviceTime(BDeviceTime bDeviceTime) {
        return bDeviceTimeMapper.updateBDeviceTime(bDeviceTime);
    }

    /**
     * 批量删除设备定时
     *
     * @param ids 需要删除的设备定时ID
     * @return 结果
     */
    @Override
    public int deleteBDeviceTimeByIds(Long[] ids) {
        return bDeviceTimeMapper.deleteBDeviceTimeByIds(ids);
    }

    /**
     * 删除设备定时信息
     *
     * @param id 设备定时ID
     * @return 结果
     */
    @Override
    public int deleteBDeviceTimeById(Long id) {
        return bDeviceTimeMapper.deleteBDeviceTimeById(id);
    }
}
